package com.jadesoft.ciadapter.library;

import java.util.ArrayList;
import java.util.List;

public class Queue<E> {
	private List<E> data ;
	
	public Queue(){
		data = new ArrayList<E>();
	}
	
	public void enqueue(E e){
		this.data.add(e);
	}
	
	public E dequeue(){
		if (this.isEmpty()){
			return null ;
		} else {
			E e = this.data.get(0);
			this.data.remove(0);
			return e;
		}
	}
	
	public void clear(){
		this.data.clear();
	}
	
	public boolean isEmpty(){
		return this.data.isEmpty();
	}
	
	public int indexOf(E obj){
		int result = -1;
		for (int i = 0,len = this.data.size() ; i < len; i++){
			if (this.data.get(i) == obj){
				result = i;
				break;
			} 
		}
		return result ;
	}
	
}
